<template>
    <div v-loading="loading">
        <Lists
            v-if="pageType === 'lists'"
            :scene="pageScene"
            @editor="handlePages"
        />

        <Editor
            v-if="pageType === 'edit' || pageType === 'add'"
            :scene="pageScene"
            :type="pageType"
            :id="editorId"
            @listen="handlePages"
        />
    </div>
</template>

<script setup lang="ts">
import Editor from './_components/editor.vue'
import Lists from './_components/lists.vue'

const loading = ref<boolean>(false)
const editorId = ref<number>(0)
const pageType = ref<string>('lists')
const pageScene = ref<string>('chat')

/**
 * 处理页面
 *
 * @param {string} scene
 * @param {string} type
 * @param {number} id
 * @author zero
 */
const handlePages = (scene: string, type: string, id: number = 0) => {
    loading.value = true
    setTimeout(() => {
        editorId.value = id
        pageType.value = type
        pageScene.value = scene
        loading.value = false
    }, 600)
}
</script>
